package com.lss.cloud.Resp;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 2024/3/14-11:21
 * 功能:
 */
@Data
@Accessors(chain = true)
public class ResultData <T>{
    private String code;
    private String message;
    private T data;
    //时间戳
    private Long timestamp;
    public ResultData(){
        this.timestamp = System.currentTimeMillis();
    }
    public static <T> ResultData<T> success(T data){
        ResultData<T> resultData = new ResultData<>();
        resultData.setData(data);
        resultData.setCode("200");
        resultData.setMessage(ReturnCodeEnum.RC200.getMessage());
        return resultData;
    }
    public static <T> ResultData<T> failed(String code,String message){
        ResultData<T> resultData = new ResultData<>();
        resultData.setData(null);
        resultData.setCode(code);
        resultData.setMessage(message);
        return resultData;
    }
}
